# 暴力搜索：
class Solution(object):
    def rotatedDigits(self, n):
        """
        :type n: int
        :rtype: int
        """
        t = {'3', '4', '7'}
        m = {'2', '5', '6', '9'}
        c = 0
        for i in range(1, n + 1):
            s = set(str(i))
            if not s & t and s & m:
                c += 1
        return c


data = Solution()
n = 100
print(data.rotatedDigits(n))
